
$(function() {
		
	var testList = $(".numdiv");
	for (i = 0; i < testList.length; i++) {
		if($(testList[i]).val() == 0) continue;
		var te = parseFloat($(testList[i]).val());
		$(testList[i]).val(comdify(te));
	}
});

function comdify(thisobj) {
	thisobj = thisobj.toString().replace(/,/g, "");
	var fl = 1;
	if(thisobj < 0){
		thisobj = -thisobj + "";
		fl = -1;
	}
	var re = /\d{1,3}(?=(\d{3})+$)/g;
	var n1 = thisobj.replace(/^(\d+)((\.\d+)?)$/,
		function(s, s1, s2) {
			return s1.replace(re, "$&,") + s2;
		});
	if(fl < 0) n1 = "-" + n1;
	return n1;
}


$(function() {
	
	$(".numdiv").keyup(function() {
	var tValue = $(this).val();
	tValue = tValue.replace(/,/g, "");
	
	var fl = 1;
	if(tValue < 0){
		tValue = -tValue + "";
		fl = -1;
	}
	
	var re = /\d{1,3}(?=(\d{3})+$)/g;
	var n1 = tValue.replace(/^(\d+)((\.\d+)?)$/, function(s, s1, s2) {
	return s1.replace(re, "$&,") + s2;
	});
	if(fl < 0) n1 = "-" + n1;
	$(this).val(n1);
});
});



